home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!raffelm
- From: raffelm@netcom.com (Matt Raffel)
- Subject: Example using vfprintf
- Message-ID: <raffelmDnK19L.IH6@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- Date: Thu, 29 Feb 1996 20:36:57 GMT
- Sender: raffelm@netcom8.netcom.com
-
- I am hoping someone can show me a simple example of
- using vfprintf. I cannot find one in the sources
- I have.
-
- I am attempting to "encapsulate" vfprintf so that
- I do not have to worry about keeping track of
- a file pointer. See code below...
-
- void lprintf(char *pszFormat, ...)
- {
- FILE *pstFile = NULL;
-
- pstFile = fopen("llog.txt", "wt+");
-
- if (pstFile)
- {
- vfprintf(pstFile, pszFormat, ...);
- fclose(pstFile);
- }
-
- }
-
- I know the above may be a bit slow with always
- opening and closing...but at least I will have
- the contents of the file when my program poofs in
- the middle in execution. :)
-
- Thanks!
-
-
- Matt
- PS: this code is for SUN Unix (if that makes
- any difference).
- --
- raffelm@netcom.com
- Web Page ftp://ftp.netcom.com/ra/raffelm/isdhome.html
- ftp://ftp.netcom.com/ra/raffelm/homeofmatt.html
-